/**
 * Created by leiweibo on 7/11/15.
 */


var app = angular.module('doctoraggregatecontroller', []);
var count = 0;

app.controller('DoctorAggregateCtrl', function ($scope, DoctorAggregateService, $routeParams) {


  var officeId = $routeParams.param;
  var pageSize = 10;
  $scope.list_by_office = function(officeId, pageNo, pageSize) {
    DoctorAggregateService.list_by_office(officeId, pageNo, pageSize, function(res) {

      if (res.result == true) {
        $scope.doctors = res.doctors;

        $scope.maxSize = 10;
        $scope.bigTotalItems = res.recordCount;
        $scope.bigCurrentPage = res.pageNo;
        $scope.itemsPerPage = res.pageSize;

        console.log(res.pageCount);
        $scope.pagenationVisible = res.pageCount > 1;

      } else {
        $scope.error_msg = res.message;
      }
    });
  };

  $scope.list_by_office(officeId, 1, pageSize);
  $scope.setPage = function (pageNo) {
    $scope.currentPage = pageNo;
  };

  $scope.pageChanged = function(page) {
    $scope.list_by_office(officeId, page, pageSize);
  };


});



